<?php
	// SimNet is a Second Life(tm) sim mangement tool that was designed for Fermi Sandbox
    // Copyright (C) 2011 Arthur Fermi
	// 
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU General Public License as published by
    // the Free Software Foundation, either version 3 of the License.
	// 
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
	//
	// To receive a copy of this license please visit http://www.gnu.org/licenses/
	
	// URL Format
	// http://<website>/simnet/simnet_eventsearch.php?Search=<Avatar Name>

	// Turn on Error Reproting remove on success
	error_reporting(E_ALL);
	ini_set('display_errors', true);

	// You should not need to edit anything below this line.
	// Get Datbase Settings
	include 'simnet_dbconfig.php';
	
	//Set Variables
	$Who = $_GET['Search'];

	// Connect to database
	$con = mysql_connect($Server, $UserName, $Password) or die("Could not connect to the server.  Error: " . mysql_error());
	mysql_select_db($database, $con) or die("Could not connect to the database.  Error: " . mysql_error());
	
	$result = mysql_query("SELECT * FROM tblSimNet_Events WHERE tblEvent_Who LIKE '$Who' ORDER BY tblEvent_Time DESC") or die(mysql_error());

	$row = mysql_fetch_array($result);
	
	// reset the result resource
	mysql_data_seek($result, 0);

	echo "------ Event Info for " . $Who . " ------" . PHP_EOL;
	while ($row = mysql_fetch_array($result)) 
	{
		echo "On " . $row['tblEvent_Time'] . " " . $Who . " was " . $row['tblEvent_Type'] . " in " . $row['tblEvent_Sim'] . " sim by " . $row['tblEvent_Staff'] . " for " . $row['tblEvent_Reason'] . " for the next " . $row['tblEvent_BanLen'] . " hours/days." . PHP_EOL;
		echo "          Comment: " . $row['tblEvent_Comment'] . PHP_EOL;
	}
	mysql_close($con);
?>